#include <iostream>
#include <vector>

#include "huffman_tree.hpp"

void print_encode(const std::vector<bool>& right)
{
	for (std::vector<bool>::const_iterator cit = right.begin(); cit != right.end(); ++cit)
	{
		if (*cit == false)
			std::cout << '0';
		else
			std::cout << '1';
	}
}

int main()
{
	using namespace std;

	vector<pair<char, int>> data = { {'a', 1}, {'b', 2}, {'c', 3}, {'d', 4}, {'e', 5}, {'f', 6} };
	huffman_tree<char, int> ht(data.begin(), data.end());

	cout << "height: " << ht.height() << endl;
	cout << "leaf count: " << ht.leaf_count() << endl;

	for (char i = 'a'; i <= 'f'; ++i)
	{
		vector<bool> ret = ht.compress(i);
		cout << "compress: ";
		print_encode(ret);
		cout << " uncompress: " << ht.uncompress(ret) << endl;
	}
	return 0;
}
